package com.hzhk.happyrent.ui.activity.order;

import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v4.view.ViewPager;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.TextView;

import com.hzhk.happyrent.R;
import com.hzhk.happyrent.ui.adapter.viewpager.ModelPreOrderAdapter;
import com.hzhk.happyrent.ui.fragment.ProductPicFragment;
import com.hzhk.happyrent.ui.view.indicator.SpringIndicator;

import java.util.ArrayList;
import java.util.List;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;

public class PreOrderDetailActivity extends AppCompatActivity {

    @BindView(R.id.activity_titlebar_left)
    ImageView activityTitlebarLeft;
    @BindView(R.id.activity_titlebar_center)
    TextView activityTitlebarCenter;
    @BindView(R.id.activity_titlebar_right)
    ImageView activityTitlebarRight;
    @BindView(R.id.act_login_submit)
    Button actLoginSubmit;
    @BindView(R.id.pre_phone_name)
    TextView prePhoneName;
    @BindView(R.id.pre_phone_state)
    TextView prePhoneState;
    @BindView(R.id.pre_phone_brand)
    TextView prePhoneBrand;
    @BindView(R.id.pre_phone_gauge)
    TextView prePhoneGauge;
    @BindView(R.id.pre_phone_rent)
    TextView prePhoneRent;
    @BindView(R.id.pre_phone_price)
    TextView prePhonePrice;
    @BindView(R.id.indicator)
    SpringIndicator indicator;
    @BindView(R.id.view_pager)
    ViewPager viewPager;
    private List<Fragment> fragments;
    private ModelPreOrderAdapter adapter;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_pre_order_detail);
        ButterKnife.bind(this);
        initView();
        initData();
    }

    private void initData() {
    }

    private void initView() {
        activityTitlebarCenter.setText(R.string.pre_phone);
        viewPager.addOnPageChangeListener(new ViewPager.OnPageChangeListener() {
            @Override
            public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {

            }

            @Override
            public void onPageSelected(int position) {
                //((ProductPicFragment) fragments.get(position)).setViewListenenr(pullUpToLoadMore);
            }

            @Override
            public void onPageScrollStateChanged(int state) {

            }
        });
        fragments = new ArrayList<>();
        fragments.add(new ProductPicFragment());
        fragments.add(new ProductPicFragment());
        fragments.add(new ProductPicFragment());
        adapter = new ModelPreOrderAdapter(getSupportFragmentManager(), fragments, this);
        viewPager.setAdapter(adapter);
        // just set viewPager
        indicator.setViewPager(viewPager);
    }

    @OnClick({R.id.activity_titlebar_left, R.id.act_login_submit})
    public void onViewClicked(View view) {
        switch (view.getId()) {
            case R.id.activity_titlebar_left:
                break;
            case R.id.act_login_submit:
                break;
        }
    }
}
